package com.leonzhangxf.guice.bill;

import com.leonzhangxf.guice.bill.domain.ChargeResult;
import com.leonzhangxf.guice.bill.domain.CreditCard;

import javax.inject.Inject;
import java.util.Map;

/**
 * paypal credit card processor impl
 *
 * @author leonzhangxf
 */
public class PaypalCreditCardProcessor implements CreditCardProcessor {

    private final String apiKey;

    private final Map<String, String> config;

    @Inject
    public PaypalCreditCardProcessor(String apiKey, Map<String, String> config) {
        this.apiKey = apiKey;
        this.config = config;
    }

    @Override
    public ChargeResult charge(CreditCard creditCard, Integer amount) throws UnreachableException {
        creditCard.charge(amount);

        System.out.println(String.format("API KEY: %s", apiKey));
        System.out.println(config);

        return new ChargeResult(true, null);
    }
}
